# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: u8sand <u8sand@gmail.com>
# Contributor: Alfredo Ramos <alfredo dot ramos at yandex dot com>

pkgname=baka-mplayer
pkgver=2.0.4
pkgrel=5
pkgdesc='A free and open source, cross-platform, libmpv based multimedia player. Qt5 build.'
arch=('loong64' 'x86_64')
url='http://bakamplayer.u8sand.net/'
license=('GPL')
depends=('mpv' 'qt5-declarative' 'qt5-svg' 'qt5-x11extras')
optdepends=('qt5-translations: for Qt5 dialog translations'
            'youtube-dl: for remote video streaming')
makedepends=('git' 'qt5-tools')
source=("$pkgname-$pkgver.tar.gz::https://github.com/u8sand/Baka-MPlayer/archive/v$pkgver.tar.gz"
        $pkgname-ceil.patch::"https://github.com/u8sand/Baka-MPlayer/commit/640cac8b.patch"
        $pkgname-mpv-2.0.patch::"https://github.com/u8sand/Baka-MPlayer/commit/7864f248c3fcd21d1dfa80700fad62785c41cba3.patch")
sha512sums=('7898d65e87540bcb528d429dc70daefc7d4c0711b2983326cf6fa3a14e566c2742334378befdb710b8cc59452f960bc17b290058ba9e6878e830de6dbafce55a'
            'd649d79fa0e594d19432f5ad88fa803c5c1d0d3fdb4a9a4f86dbad298e95a127296eb40033fbf41383521f9179d1e257d78d458ff9f77fa02cfc786906a033e3'
            '088649177e0add695b0bd3ff8f1d7c9921e899ba3a9c933a15f772ecd019fa2b1e170807e5111502dab178575a8ada13ea58774a84f002667edba7b0c1fbfc34')

prepare() {
  # Make build directory
  mkdir -p build

  cd Baka-MPlayer-$pkgver
  patch -p1 -i ../$pkgname-ceil.patch # Fix build with GCC 7
  patch -p1 -i ../$pkgname-mpv-2.0.patch
}

build() {
  # Building package
  cd build
  qmake-qt5 ../Baka-MPlayer-$pkgver/src \
    CONFIG+=release \
    CONFIG+=install_translations \
    -spec linux-g++
  make -j$(nproc)
}

package() {
  # Installing package
  cd build
  make INSTALL_ROOT="$pkgdir" install
}
